// Extract.h

#ifndef __EXTRACT_H
#define __EXTRACT_H

#include "Common/FileSystem/FileFind.h"

#include "IArchive.h"

#include "ArchiveExtractCallback.h"
#include "ArchiveOpenCallback.h"
#include "ExtractMode.h"
#include "Common/Props/Property.h"

#include "LoadCodecs.h"

namespace Common
{
namespace Archive
{
struct CExtractOptions
{
  bool StdInMode;
  bool StdOutMode;
  bool YesToAll;
  bool TestMode;
  bool CalcCrc;
  Extract::PathMode PathMode;
  Extract::OverwriteMode OverwriteMode;
  CString OutputDir;
  
  // bool ShowDialog;
  // bool PasswordEnabled;
  // CString Password;
  #if !defined(_7ZIP_ST) && !defined(_SFX)
  std::vector<Props::CProperty> Properties;
  #endif

  #ifdef EXTERNAL_CODECS
  CCodecs *Codecs;
  #endif

  CExtractOptions():
      StdInMode(false),
      StdOutMode(false),
      YesToAll(false),
      TestMode(false),
      CalcCrc(false),
      PathMode(Archive::Extract::PathMode::kFullPathnames),
      OverwriteMode(Archive::Extract::OverwriteMode::kAskBefore)
      {}
};

struct CDecompressStat
{
  UINT64 NumArchives;
  UINT64 UnpackSize;
  UINT64 PackSize;
  UINT64 NumFolders;
  UINT64 NumFiles;
  UINT32 CrcSum;

  void Clear()
  {
    NumArchives = UnpackSize = PackSize = NumFolders = NumFiles = 0;
    CrcSum = 0;
  }
};

HRESULT DecompressArchives(
    CCodecs *codecs, const std::vector<int> &formatIndices,
    std::vector<CString> &archivePaths, std::vector<CString> &archivePathsFull,
    const Common::FileSystem::Wildcard::CCensorNode &wildcardCensor,
    const CExtractOptions &options,
    IOpenCallbackUI *openCallback,
    IExtractCallbackUI *extractCallback,
    CString &errorMessage,
    CDecompressStat &stat);

}

}


#endif
